// userAPI.ts

import { request } from "../utils/request";

/**
 * 根据用户 ID 获取用户信息
 * @param userId 用户 ID
 */
export const getUserInfoById = (userId: number) => {
    return request({
        url: `/user/${userId}`,
    });
}

/**
 * 根据用户 ID 获取用户详细信息
 * @param userId 用户 ID
 */
export const getUserInfo = (userId: number) => {
    return request({
        url: `/user/info/${userId}`,
    });
}

/**
 * 查询所有优惠券
 */
export const getCoupons = () => {
    return request({
        url: `/coupon/all`,
    });
}
/*
* 查询用户优惠券
*/
export const getUserCoupons = (userId: number) => {
    return request({
        url: `/coupon/user/${userId}`,
    })
}

/**
 * 兑换优惠券
 */
export const exchangeCoupon = (data:any) => {
    return request({
        method: 'POST',
        url: '/coupon/exchange',
        data:data,
    });
}
/**
 * 根据用户 ID 获取用户发布的帖子
 * @param userId 用户 ID
 */
export const getUserPosts = (userId: number) => {
    return request({
        url: `/articles/user/${userId}`,
    });
}

export const followUser = (data:any)=>{
    return request({
        url:"/user/follow",
        method:"POST",
        data:data
    })
}

export const unFollowUser = (data:any)=>{
    return request({
        url:"/user/unfollow",
        method:"POST",
        data:data
    })
}
